Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19

Warning: Function ereg() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 4

Warning: Function split() is deprecated in ..../includes/class_postbit.php(345) : eval()'d code on line 19
Where should I store my data?
Results 1 to 7 of 7

Thread: Where should I store my data?

  1. #1
    Senior Member
    Join Date
    Jul 2001
    Posts
    280

    Where should I store my data?

    OK, this is an odd question. Lets say I have a large block of static data for use by a program I'm writing. This data never changes; it is 100% immutable. However, there is a lot of if (say, 3k). Where should I store the data?

    I can hardcode the data into the program, read the data from a file at the program's startup, or read the data from the file whenever it is needed.

    Loading the data from a file is slow, but it offers me the unnecessary ability to change the data w/o recompiling and even while the program in running. However, as I said, I will never need to change this data; in fact, this data can not be changed and must be present.

    Another benefit of loading the data from a file is it is not stored in the executable, thus not enlarging the executable. Since speed is very important here, loading the data from a file at the program's startup would be acceptable since the data would be in memory when it is needed.

    The biggest advantages of hardcoding the data is speed and ease. I have no need for file i/o with hardcoded data, and that also eliminates the possibility for this data to be missing or be altered. Again, the data is necessary for the execution program and can not be altered.

    In the days before cheap ram, loading from a file on use would probably be the best way, however, 3k of data in the ram is probably not going to choke most systems today. What do you think? Thanks.

  2. #2
    Guest

    Re:Where should I store my data?

    I say hardcode, mostly because it's probably easiest to maintain.

  3. #3
    Senior Member
    Join Date
    Jul 2001
    Posts
    280

    Re:Where should I store my data?

    I agree. But what if there was 40k of data instead of just 3k? Would your opinion change with the size of the data to be stored? If yes, what would be the point where you would change your opinion?

  4. #4

    Re:Where should I store my data?

    Well, if you had some data that your program needs, there are a few places that you can put it:

    /etc if it is configuration-related data,
    /home/$USER if it the data is per-user, or
    /usr/share/programname if the data is global (not per-user) and not really configuration-related.

    Have a look around at /usr/share, see what kinds of things other programs put there.

  5. #5
    Senior Member
    Join Date
    Jul 2001
    Posts
    280

    Re:Where should I store my data?

    [quote author=Feztaa link=board=9;threadid=4142;start=0#41132 date=1026538321]
    Well, if you had some data that your program needs, there are a few places that you can put it:

    /etc if it is configuration-related data,
    /home/$USER if it the data is per-user, or
    /usr/share/programname if the data is global (not per-user) and not really configuration-related.

    Have a look around at /usr/share, see what kinds of things other programs put there.
    [/quote]

    Well, if I were to store the data in a file, those are some places I could put it.

  6. #6

    Re:Where should I store my data?

    Either way, you're going to have to load the data from disk into memory, either when you first run the program, or sometime later. If the data are needed throughout the execution of the program, then I would say hardcode. If they are only needed at a certain point in execution, or if there's a possibility they won't be needed at all, then load from a file.

  7. #7
    Moderator
    Good Guru
    Schotty's Avatar
    Join Date
    Jul 2001
    Location
    Milwaukee, WI
    Posts
    5,760

    Re:Where should I store my data?

    My opinion is as follows :: It depends on HOW you want to use the program (on a high load server) and WHAT type of a system will be using it.

    Let me clarify a bit. A high load server would probably be better suited with it hardcoded if you are using a lot of disk accesses. If your machine is lower end or hurting for RAM, leave it out and use some disk I/O calls to grab the pieces as needed. 3K is 3K, but I have seen some servers that could be thrown way off into disk pageland hell by adding just that amount (not the greatest of servers to administer, trust me). Think about how your system is going to be utilized and customize it for that. If you have the RAM use it up with the data. Especially if it is a headless server. Not having X in the way does wonders on the system load and need to page out to your pagefile ;D

Similar Threads

  1. Email catcher and store
    By datamike in forum Linux - General Topics
    Replies: 1
    Last Post: 08-06-2004, 05:14 PM
  2. funny store name in edinburgh...
    By seanmclemon in forum General Chat
    Replies: 6
    Last Post: 07-28-2004, 08:19 PM
  3. What is in the store bought RH8.0
    By Rastar in forum Linux - General Topics
    Replies: 1
    Last Post: 01-22-2003, 04:40 PM
  4. ~lart local record store !!
    By in forum General Chat
    Replies: 22
    Last Post: 05-22-2002, 01:59 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •