Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

BBCode handling

 
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
While creating my forum, I have come across the problem of dealing with BBCode, and there are many options available so I thought I might check how JForum does it and if you had considered/discarded other approaches.

The problem with BBCode handling is that to implement it one usually ends up applying regular expressions to the message content, and sometimes not one but many times (one per BBCode maybe?). I implemented an algorithm to minimize the number of regular expressions and temporary Strings created, but in spite of that I keep wondering if I want to apply that process to each message that is displayed, every time that it is displayed.

So I thought I might add the option of storing the BBCode-processed content inside the DB as well, so it is just processed once, when the message is created. This would pretty much double the space used for the DB, so I would also allow this option to be "disabled", swapping CPU per Hard Disk.

But I'm still not really satisfied with that so I thought that another option would be to store the BBCode processed version in the DB and just apply the transformation "backwards" when you need the "unprocessed" version, which will probably be used less often (just when quoting?).

Moreover, if you cache message contents once they are processed, then the problem is not such problem, but then you need more memory for your application, and you would still incurr in high CPU usage when loading the cache. So I think the problem might still be valid even when using a cache...

So... what do you think? Have you tried any of this alternatives? Right now I'm leaning towards the option of storing the processed version on the DB... but will it pay off? That's the million-dollar question .

Cheers
[originally posted on jforum.net by GreenEyed]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is the "always process bbcode" behaviour killing your system? otherwise, I'll not worry for such improvement. Not using regular expressions might be a little better than when using it, if well done, but I have my doubts if the added complexity will pay the effort.

I would go with HTML caching, besides the fist "keep it in memory" approach.

Rafael
[originally posted on jforum.net by Rafael Steil]
 
Migrated From Jforum.net
Ranch Hand
Posts: 17424
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well,

It's not killing my system... as I still don't have a system to kill ;). I'm developing it so I still don't have field-tests.

Regarding HTML caching... to do it properly it is actually much more complex than simply storing twice the size of some messages. Keeping messages in memory is also something I'm not very keen on doing, HD is cheaper than RAM and Java applications already consume enough memory. Moreover, it is something not easily done.

Let's see if I can get a few tests done....
[originally posted on jforum.net by GreenEyed]
 
Eliminate 95% of the weeds in your lawn by mowing 3 inches or higher. Then plant tiny ads:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic