Re: 1.5.4: Rather curious case of the IInitializer List

2012-02-14 Thread richard emberson

Since the intent is to access the latest snapshot of the
Application IInitializer list, why not simply have the
InitializerStringResourceLoader loadStringResource
method call
Application.get().getInitializers().

I would suggest that it is cleaner.

And, yes, I know that Java's unmodifiableList is a flawed
attempt at having a cheap mutable to immutable transformation.
Sadly, its the best Java standard library can offer.

Richard

On 02/14/2012 01:19 AM, Sven Meier wrote:

Hi Richard,

you're right, this implementation looks 'curious' but it was intentional.

Note the javadoc of Collection.unmodifiableList():
'Query operations on the returned list read through to the specified
list'

Sven


Am 13.02.2012 23:58, schrieb richard emberson:

While looking at the extensions code,
I noted that in the 1.5.4 InitializerStringResourceLoader
constructor that the list of IInitializer is empty but
in the InitializerStringResourceLoader loadStringResource
method there are two initializers in that same IInitializer list.

So, how can this be?

Well, in Application, first the initializers list is
wrapped in a Collections.unmodifiableList and returned
by the Application getInitializers method. This is
called when creating an instance of the InitializerStringResourceLoader.
Later, the Application load(properties) method is called
which, in turn, calls addInitializer twice which adds
two IInitializer to the Application's initializers list.

Now, the InitializerStringResourceLoader loadStringResource
is called and, behold, the InitializerStringResourceLoader
IInitializer list now has two members.

It seems that, under the covers, Application and
InitializerStringResourceLoader
share the same IInitializer list!!! This sharing is, well,
not documented, rather, its depends upon the implementation of
Collections.unmodifiableList.

So, I don't wish to criticize; maybe this was the intent;
maybe its very clever; but for me its, well, curious.

Richard




-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org




--
Quis custodiet ipsos custodes

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



1.5.4: Rather curious case of the IInitializer List

2012-02-13 Thread richard emberson

While looking at the extensions code,
I noted that in the 1.5.4 InitializerStringResourceLoader
constructor that the list of IInitializer is empty but
in the InitializerStringResourceLoader loadStringResource
method there are two initializers in that same IInitializer list.

So, how can this be?

Well, in Application, first the initializers list is
wrapped in a Collections.unmodifiableList and returned
by the Application getInitializers method. This is
called when creating an instance of the InitializerStringResourceLoader.
Later, the Application load(properties) method is called
which, in turn, calls addInitializer twice which adds
two IInitializer to the Application's initializers list.

Now, the InitializerStringResourceLoader loadStringResource
is called and, behold, the InitializerStringResourceLoader
IInitializer list now has two members.

It seems that, under the covers, Application and 
InitializerStringResourceLoader

share the same IInitializer list!!! This sharing is, well,
not documented, rather, its depends upon the implementation of
Collections.unmodifiableList.

So, I don't wish to criticize; maybe this was the intent;
maybe its very clever; but for me its, well, curious.

Richard

--
Quis custodiet ipsos custodes

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Page De-Serialization and memory

2011-07-20 Thread richard emberson
) and third
(disk)). First level (http session) contains page instances (not
serialized). Check https://cwiki.apache.org/confluence/x/qIaoAQ for
more information.

RAM and especially HDD are cheap today, so I think the benefit of your
optimization will not be big. As a proof I can say that there are no
complains in the mailing lists that Wicket produces too big files for
the third level cache. The general complain is that http session
footprint is bigger than action-based web frameworks but I think this
is because using custom o.a.w.Session is so comfortable that people
start putting a lot of state there. The next reason is first-level
cache but even this is easy to solve - just implement custom
IPageManager or override the default one to not use http session as
first level cache.

Recently we reworked a bit the code related to page serialization and
now it is possible to use any library specialized in object
serialization (see https://github.com/eishay/jvm-serializers/wiki).
The schema based ones (like Apache Avro, Thrift, Protobuf, ...) will
be harder to use but not impossible.
The schemaless ones (Java Serialization, Kryo, XStream, ...) are
easier to use with Wicket. You may check Kryo based serializer at
https://github.com/wicketstuff/core/tree/master/jdk-1.6-parent/serializer-kryo
. It is faster than Java Serialization and produces less bytes.

On Wed, Jul 20, 2011 at 2:43 AM, richard emberson
richard.ember...@gmail.com  wrote:

Martin,

The reason I was interested in Wicket memory usage was because
of the potential use of Scala traits, rather than the two possible
Java approaches, might be compelling when it comes to memory usage.

First, the two Java approaches: proxy/wrapper object or bundle everything
into the base class.

The proxy/wrapper approach lets one have a single implementation
that can be share by multiple classes. The down side is that
proxy/wrapper object requires an additional reference in the
class using it and hence additional memory usage.

The bundle everything into the base class approach violates
OOP 101 dictum about having small objects focused on their
own particular behavior thus avoiding bloat.
(Not executable Java/Scala code below.)

interface Parent {
  getParent
  setParent
}
// Potentially shared implementation
class ParentProxy implements Parent {
  parent
  getParent = parent
  setParent(parent) = this.parent = parent
}

// Issue: Has additional instance variable: parentProxy
class CompWithProxy with Parent {
  parentProxy = new ParentProxy
  getParent = parentProxy.getParent
  setParent(parent) = parentProxy.setParent(parent)
}

// Issue: Does not share implementation
class CompAllInOne with Parent {
  parent
  getParent = parent
  setParent(parent) = this.parent = parent
}

Wicket has taken the bundle everything into base class in order
to lessen memory usage - a certainly reasonable Java approach
to the problem.

With Scala one can do the following:

// Shared implementation
trait ParentTrait {
  parent
  getParent = parent
  setParent(parent) = this.parent = parent
}

// Uses implementation
class Comp with ParentTrait

The implementation, ParentTrait, can be used by any
number of classes.
In addition, one can add to a base class any number of
such implementation traits sharing multiple implementations
across multiple classes.

So, can using such approach result in smaller (less in-memory)
object in Scala than in Java?

The ParentTrait does not really save very much. I assume
that its only the Page class and sub-classes that do not have
parent components in Wicket, so the savings per Page component
tree is very small indeed. But, there are other behaviors that
can be converted to traits, for example, Models.
Many of the instance variables in the Java Models which
take memory can be converted to methods return values which only
add to the size of the class, not to every instance of the class.
Also, with Model traits that use Component self-types, one can
do away with IComponentAssignedModel wrapping and such.

So, how to demonstrate such memory differences. I created
stripped down versions of the Component and Label classes in
both Java and Scala (only ids and Models) .
Created different Model usage scenarios
with Model object in Java and Traits in Scala, and, finally,
serialized (Java Serialization) the result comparing the size
of the resulting array of bytes. There are two runs, one with
all Strings being the empty string and the next where all
strings are 10-character strings:

The Java versions (empty string):
Label.Empty   99
Label.ReadOnly   196
Label.ReadWrite  159
Label.Resource   333
Label.Property   223
Label.ComponentProperty  351
Label.CompoundProperty   208

The Scala versions (empty string):
Label.Empty  79
Label.ReadOnly   131
Label.ReadWrite  150
Label.Resource   164
Label.Property   207
Label.ComponentProperty  134
Label.CompoundProperty   184


The Java versions (10

Re: Page De-Serialization and memory

2011-07-20 Thread richard emberson

Thanks Igor.

 it is not allowed, see page#componentRendered()
Thanks.

 sharing component instances between pages
I am going to have to think about all of this.
Maybe making mutable and immutable version of things
or, maybe, an Immutable trait (interface) that signals
intent (but, of course, would not enforce it).

 that is a bad example

Maybe here's a better example (actually, a rather extreme example):

org/apache/wicket/util/upload/ParameterParser.java

  private def isOneOf(ch: Char, charray: Array[Char]): Boolean =
charray exists { _ == ch }

  private boolean isOneOf(final char ch, final char[] charray)
  {
boolean result = false;
for (char character : charray)
{
  if (ch == character)
  {
result = true;
break;
  }

}
return result;
  }

I am not trying to (re-)start any wars here.
I do not think its all due to formatting.
Currently, for 1.5-RC5.1 loc:
Java Wicket:  154556
Scala Wicket: 118617
and its not really possible to use some of the more-terse
aspects of Scala because that would require a rather larger
porting/re-writing effort.


Richard

On 07/20/2011 09:44 AM, Igor Vaynberg wrote:

On Wed, Jul 20, 2011 at 9:00 AM, richard emberson
richard.ember...@gmail.com  wrote:

I have many examples of such Java bloat. Consider the getKey method
in the org/apache/wicket/util/value/ValueMap.java class:

Java version:

  public String getKey(final String key)
  {
for (Object keyValue : keySet())
{
  if (keyValue instanceof String)
  {
String keyString = (String)keyValue;
if (key.equalsIgnoreCase(keyString))
{
  return keyString;
}
  }
}
return null;
  }

Scala version:

  def getKey(key: String): Option[String] =
keySet find { s =  key.equalsIgnoreCase(s) }


that is a bad example. that method was there since the times valuemaps
supported non-string keys, thats what all the noise was about. your
code doesnt support non string keys, and i just cleaned it up ours so
it doesnt have to worry about it either. thanks for pointing it out :)

here it is in its concise form :
public String getKey(String key) {
for (String other : keySet()) if (other.equalsIgnoreCase(key)) return 
other;
return null;
}

it all depends on formatting


The Scala version reads like a sentence: For the keys find
the key which equals, ignoring case, the key parameter.
The Java code is just so sad in comparison.


not in my concise version, though, is it? however, the concise version
is harder for some people to read, so we use very generous formatting
rules when it comes to spacing and curly braces.


I did have 2 questions buried in my previous email.
Both having to do with serialization of an object when
it appears as 2nd (3rd, etc.) time during the serialization
process.


serialization handles multiple references to the same instance. so if
you have the same instance showing up more then once in the
serialization graph it is only written out once. this is how circular
references are handled as well.


So, first, is it possible, likely, allowed, excluded, etc. that
the same Component can appear more than once in the same
Page tree? Would it make sense or even be possible for the
same Form object to appear more than once in the same Page tree?
Not two copies of a Form, but the single instance in two places
on a Page?
If it should never happen, is there code in Wicket that ensures
that it does not happen?


it is not allowed, see page#componentRendered()


Secondly, for a Component that is immutable in a given Page,
could it appear, be reused, in the same Page in different
Sessions (different clients)? Other areas of such Pages would
be different, hold different data, but could the immutable part
be same object? As an example, a read-only Label object, could
it be used in the same place in the same Page type but in
different Sessions? Is there any mechanism in Wicket currently
that could identify such possible reuse?


sharing component instances between pages is a bad idea, sharing them
between sessions is even worse. code is constantly refactored, what is
immutable now will most likely not be immutable later. i would hate
coding wicket if every time i made a change to someone else's
component i would have to check if i just made something immutable
mutable and possibly cause a security leak.

-igor



After memory comes performance and thats a much harder nut to
crack. To track down bugs in the Scala port I had to put
detailed logging into both the Java and Scala versions.
What was most surprising was the amount a code that
had to be execute, multiple times, just to render the
simplest Page in a unit test - tens of pages of logging
output. I do not understand all that is truly happening
within Wicket to render a Page yet, but its on my todo list.
And, maybe, there is no issue.

Richard
Thanks.


On 07/20/2011 03:04 AM, Martin Grigorov wrote:


Hi Richard,

1. Scala traits are something useful

Re: Page De-Serialization and memory

2011-07-20 Thread richard emberson




lol, so scala has a built in isOneOf, of course it wins there...this
is of course a non-example. im not sure why some of our code is so
bloated, its been there for years. i cleaned this one up to, here is
the concise version:

private boolean isOneOf(final char ch, final char[] charray) {
for (char c : charray) if (c==ch) return true;
return false;
}
what does the scala code for exists() look like? :)


Good re-write.
The Scala exists code pretty much looks like a generic version
of the isOneOf code.
The FP folks would point out that the difference is that there
are a bunch of such canned methods on all collection objects
and they are designed to be chained together.

--
Quis custodiet ipsos custodes

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Page De-Serialization and memory

2011-07-20 Thread richard emberson



On 07/20/2011 10:03 AM, Martin Grigorov wrote:

Hi Richard,

With the serialization optimizations you optimize only the second and
third level stores, i.e. the runtime memory is still the almost same.
You'll gain only if you have bigger second level cache which is used
when the user uses browser back button. And I think this is no so
often.

Just a thought and maybe a little off topic,
What if, when a Page is first generated, when it is first
loaded given its class, prior to use, the Page is serialized and
the bytes are put into a cache Map from class name to bytes.
Then, subsequent times the page is request (same session or
different session), it is found in the cache and simply
de-serialized.
Would it work?
Would it be better (choose some criteria)?
Thanks



About Scala vs. Java consciousness: I guess you read this thread -
http://groups.google.com/group/scala-user/browse_thread/thread/ea4d4dda2352a523#
Here and in the previous thread on this topic the functional guys
suggest solutions which I think are not that easy to read and as
proven the speed is far from the imperative solution. Oderski explains
it well in his response.

Ha. Yea, I have been following that discussion.
I tend to write OO-Scala and not FP-Scala.
Partly because that is the way my mind works but also
because if FP was so great, Lisp would have ended the discussion
(or may Haskell would have) and all enterprise applications would
be written in Lisp - but, of course, if you search the IBM/Oracle/SAP
sites you don't find any Lisp enterprise applications for sale
(ok, having said this, someone will find one, I admit defeat, etc.).
Also, its a lot easier to understand, debug and log OO vs FP code
(but, again, that is just my enterprise application development
background speaking).



About the questions - the simple answer is that a Component can have
just one parent, so it is not possible to reuse it neither in the same
page nor in different page. The same is true about its collection of
children. This is the current state.

Well, I guess the immutable Component would have to have a mutable
parent reference.

Thanks
Richard
--
Quis custodiet ipsos custodes

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Bigger sites running on wicket?

2011-07-20 Thread richard emberson

I looked at the Page source for about 10 pages and could not
tell that they were generated using Wicket.
Are there some telltale indicators that might indicate
Wicket usage?
Yea, inside knowledge is one indicator, but I mean some
other indicator. Something about the HTML or such?

Thanks

Richard

On 07/20/2011 12:57 PM, dryajov wrote:

Well, bodybuilding.com is beginning to use wicket extensively, there are
several parts of the website ported to wicket (store excluded) already and a
major revamp is being worked on as we speak - all in wicket. That is by far
the biggest site that uses wicket AFAIK.

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Bigger-sites-running-on-wicket-tp2197500p3681916.html
Sent from the Users forum mailing list archive at Nabble.com.

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org




--
Quis custodiet ipsos custodes

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Page De-Serialization and memory

2011-07-19 Thread richard emberson
 tests exactly this - the heap space.
I'll try the app with MemoryMXBean to see whether the non-heap changes
after deserialization.
I'm not very into Java Serialization but indeed it seems the Strings
are deserialized in the heap. But even in this case they go in the
Eden space, i.e. they are reclaimed soon after.

On Sun, Jul 10, 2011 at 2:37 AM, richard emberson
richard.ember...@gmail.com  wrote:

I you run the little Java program I included, you will see that
there is an impact - de-serialized objects take more memory.

Richard

On 07/09/2011 05:23 PM, Igor Vaynberg wrote:


string literals are interned by the jvm so they should have a minimal
memory impact.

-igor

On Sat, Jul 9, 2011 at 5:10 PM, richard emberson
richard.ember...@gmail.comwrote:


Martin,

The reason I was interested was because it struck me a couple of
days ago that while each Page, tree of Components, is created
many (almost all?) of the non-end-user-generated Strings stored
as instance variables in the tree are shared
between all copies of the Page but that when such a Page is
serialized to disk and then de-serialized, each String becomes its own
copy unique to that particular Page. This means that if an
appreciable number of Pages in-memory are reanimated Pages, then
there could be a bunch of memory being used for all the String
copies.

In the attached simple Java file (yes, I still write Java when I must)
there are three different ways of creating an array of
Label objects (not Wicket Label) where each Label takes a String:
new Label(some_string)

The first is to share the same String over all instance of the Label.
new Label(the_string)
The second is to make a copy of the String when creating each
Label;
new Label(new String(the_string))
The third is to create a single Label, serialize it to an array of
bytes and then generate the Labels in the array by de-serialized
the byte array for each Label.

Needless to say, the first uses the least memory; the label string
is shared by all Labels while the second and third approach
uses more memory. Also, if during the de-serialization process, the
de-serialized String is replaced with the original instance of the
String, then the third approach uses only as much memory as the
first approach.

No rocket science here, but it does seem to imply that if a
significant number of Pages in-memory are actually reanimated Pages,
then there could be a memory saving by
making de-serialization smarter about possible shared objects.
Even it it is only, say, a 5% saving for only certain Wicket
usage patterns, it might be worth looking into.

Hence, my question to the masters of Wicket and developers whose
application might fit the use-case.

Richard

On 07/09/2011 11:03 AM, Martin Makundi wrote:


Difficult to say ... we have disabled page versioning and se dump
sessions onto disk every 5 minutes to minimize memory hassles.

But I am no master ;)

**
Martin

2011/7/9 richard embersonrichard.ember...@gmail.com:


This is a question for Wicket masters and those application builders
whose application match the criteria as specified below.

[In this case, a Wicket master is someone with a knowledge
of how Wicket is being used in a wide spectrum of applications
so that they have a feel for what use-cases exist in the real world.]

Wicket is used in a wide range of applications with a variety of
usage patterns. What I am interested in are those applications where
an appreciable number of the pages in memory are pages that had
previously been serialized and stored to disk and then reanimated,
not found in an in-memory cache and had to be read from disk and
de-serialized back into an in-memory page; which is to say,
applications with an appreciable number of reanimated pages.

Firstly, do such applications exists? These are real-world
applications where a significant number of pages in-memory
are reanimated pages.

For such applications, what percentage of all pages at any
given time are reanimated pages?
Is it, say, a couple of percent? Two or three in which case its not
very significant.
Or, is it, say, 50%? Meaning that half of all pages currently in
memory had been serialized to disk, flushed from any in-memory cache
and then, as needed, de-serialized back into a Page.

Thanks

Richard
--
Quis custodiet ipsos custodes

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org




--
Quis custodiet ipsos custodes


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Re: Page De-Serialization and memory

2011-07-11 Thread richard emberson

When you say 1 times, you set NOS_TIMES to 1?
(NOS_TIMES should have been called ARRAY_SIZE).

Richard

On 07/11/2011 05:38 AM, Martin Grigorov wrote:

Running the third method (the 'problematic' one) 1 times shows no
changes in the PermGen space in VisualVM graphics.
The value is stable at 7.9Mb.

MemoryMXBean shows that non-heap space increases more than heap space
but I didn't find any resource explaining what is included in this
non-heap statistics.

The proof that PermGen is quite stable can be seen with:  -verbose:gc
-XX:+PrintGCDetails

It produces something like:
[Full GC (System) [PSYoungGen: 0K-0K(76480K)] [PSOldGen:
1372K-1372K(174784K)] 1372K-1372K(251264K) [PSPermGen:
6746K-6746K(16384K)], 0.0198550 secs] [Times: user=0.01 sys=0.00,
real=0.02 secs]

Comparing several such outputs shows that PermGen is stable (not
increasing, not decreasing).

Almost all of the memory allocation happens in the YoungGen and rarely
in the OldGen. This is normal because Label objects are created and
then discarded.

On Sun, Jul 10, 2011 at 11:37 AM, Martin Grigorovmgrigo...@apache.org  wrote:

Hi,

About the use cases: my experience is that most of the time the uses
the in-memory pages (for each listener callback execution, for ajax
requests,...).
Previous version of a page, or previous page is needed when the user
clicks browser back button. Even in this case most of the time the
in-memory cache is hit. Only when the user goes several pages back and
this page is not in-memory then the disk store is used.

So far so good, but...! Even in-memory store contains serialized
versions of the Page, named SerializedPage. This is a struct which
contains
{
  sessionId: String,
  pageId: int,
  data: byte[]
}
so the Page is serialized back and forth when stored in *any*
IPageStore/IDataStore.

This is the current state in Wicket 1.5.

Me and Pedro noticed that IPageStore impl (DefaultPageStore) can be
improved to work with Page instances but we decided to postpone this
optimization for 1.5.0+.

About new String(someLiteral): I don't remember lately seeing this
code neither in libraries, nor in applications. This constructor
should be used only when the developer explicitly wants this string to
not be interned and stored in the PermGen space, i.e. it will be
stored in the heap space.
Your benchmark test tests exactly this - the heap space.
I'll try the app with MemoryMXBean to see whether the non-heap changes
after deserialization.
I'm not very into Java Serialization but indeed it seems the Strings
are deserialized in the heap. But even in this case they go in the
Eden space, i.e. they are reclaimed soon after.

On Sun, Jul 10, 2011 at 2:37 AM, richard emberson
richard.ember...@gmail.com  wrote:

I you run the little Java program I included, you will see that
there is an impact - de-serialized objects take more memory.

Richard

On 07/09/2011 05:23 PM, Igor Vaynberg wrote:


string literals are interned by the jvm so they should have a minimal
memory impact.

-igor

On Sat, Jul 9, 2011 at 5:10 PM, richard emberson
richard.ember...@gmail.comwrote:


Martin,

The reason I was interested was because it struck me a couple of
days ago that while each Page, tree of Components, is created
many (almost all?) of the non-end-user-generated Strings stored
as instance variables in the tree are shared
between all copies of the Page but that when such a Page is
serialized to disk and then de-serialized, each String becomes its own
copy unique to that particular Page. This means that if an
appreciable number of Pages in-memory are reanimated Pages, then
there could be a bunch of memory being used for all the String
copies.

In the attached simple Java file (yes, I still write Java when I must)
there are three different ways of creating an array of
Label objects (not Wicket Label) where each Label takes a String:
new Label(some_string)

The first is to share the same String over all instance of the Label.
new Label(the_string)
The second is to make a copy of the String when creating each
Label;
new Label(new String(the_string))
The third is to create a single Label, serialize it to an array of
bytes and then generate the Labels in the array by de-serialized
the byte array for each Label.

Needless to say, the first uses the least memory; the label string
is shared by all Labels while the second and third approach
uses more memory. Also, if during the de-serialization process, the
de-serialized String is replaced with the original instance of the
String, then the third approach uses only as much memory as the
first approach.

No rocket science here, but it does seem to imply that if a
significant number of Pages in-memory are actually reanimated Pages,
then there could be a memory saving by
making de-serialization smarter about possible shared objects.
Even it it is only, say, a 5% saving for only certain Wicket
usage patterns, it might be worth looking into.

Hence, my question to the masters of Wicket

Page De-Serialization and memory

2011-07-09 Thread richard emberson

This is a question for Wicket masters and those application builders
whose application match the criteria as specified below.

[In this case, a Wicket master is someone with a knowledge
of how Wicket is being used in a wide spectrum of applications
so that they have a feel for what use-cases exist in the real world.]

Wicket is used in a wide range of applications with a variety of
usage patterns. What I am interested in are those applications where
an appreciable number of the pages in memory are pages that had
previously been serialized and stored to disk and then reanimated,
not found in an in-memory cache and had to be read from disk and
de-serialized back into an in-memory page; which is to say,
applications with an appreciable number of reanimated pages.

Firstly, do such applications exists? These are real-world
applications where a significant number of pages in-memory
are reanimated pages.

For such applications, what percentage of all pages at any
given time are reanimated pages?
Is it, say, a couple of percent? Two or three in which case its not
very significant.
Or, is it, say, 50%? Meaning that half of all pages currently in
memory had been serialized to disk, flushed from any in-memory cache
and then, as needed, de-serialized back into a Page.

Thanks

Richard
--
Quis custodiet ipsos custodes

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Page De-Serialization and memory

2011-07-09 Thread richard emberson

Martin,

The reason I was interested was because it struck me a couple of
days ago that while each Page, tree of Components, is created
many (almost all?) of the non-end-user-generated Strings stored
as instance variables in the tree are shared
between all copies of the Page but that when such a Page is
serialized to disk and then de-serialized, each String becomes its own
copy unique to that particular Page. This means that if an
appreciable number of Pages in-memory are reanimated Pages, then
there could be a bunch of memory being used for all the String
copies.

In the attached simple Java file (yes, I still write Java when I must)
there are three different ways of creating an array of
Label objects (not Wicket Label) where each Label takes a String:
new Label(some_string)

The first is to share the same String over all instance of the Label.
new Label(the_string)
The second is to make a copy of the String when creating each
Label;
new Label(new String(the_string))
The third is to create a single Label, serialize it to an array of
bytes and then generate the Labels in the array by de-serialized
the byte array for each Label.

Needless to say, the first uses the least memory; the label string
is shared by all Labels while the second and third approach
uses more memory. Also, if during the de-serialization process, the
de-serialized String is replaced with the original instance of the
String, then the third approach uses only as much memory as the
first approach.

No rocket science here, but it does seem to imply that if a
significant number of Pages in-memory are actually reanimated Pages,
then there could be a memory saving by
making de-serialization smarter about possible shared objects.
Even it it is only, say, a 5% saving for only certain Wicket
usage patterns, it might be worth looking into.

Hence, my question to the masters of Wicket and developers whose
application might fit the use-case.

Richard

On 07/09/2011 11:03 AM, Martin Makundi wrote:

Difficult to say ... we have disabled page versioning and se dump
sessions onto disk every 5 minutes to minimize memory hassles.

But I am no master ;)

**
Martin

2011/7/9 richard embersonrichard.ember...@gmail.com:

This is a question for Wicket masters and those application builders
whose application match the criteria as specified below.

[In this case, a Wicket master is someone with a knowledge
of how Wicket is being used in a wide spectrum of applications
so that they have a feel for what use-cases exist in the real world.]

Wicket is used in a wide range of applications with a variety of
usage patterns. What I am interested in are those applications where
an appreciable number of the pages in memory are pages that had
previously been serialized and stored to disk and then reanimated,
not found in an in-memory cache and had to be read from disk and
de-serialized back into an in-memory page; which is to say,
applications with an appreciable number of reanimated pages.

Firstly, do such applications exists? These are real-world
applications where a significant number of pages in-memory
are reanimated pages.

For such applications, what percentage of all pages at any
given time are reanimated pages?
Is it, say, a couple of percent? Two or three in which case its not
very significant.
Or, is it, say, 50%? Meaning that half of all pages currently in
memory had been serialized to disk, flushed from any in-memory cache
and then, as needed, de-serialized back into a Page.

Thanks

Richard
--
Quis custodiet ipsos custodes

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org




--
Quis custodiet ipsos custodes

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.IOException;

import java.io.Serializable;
import java.lang.Runtime;

class JMain {
  static class Label implements Serializable { 
public String v;
public Label(String v) {
this.v = v;
}
  }

  static final String LABEL_VALUE = 0123456789;
  static final int NOS_TRIALS = 10;
  //static final int NOS_TIMES = 1;
  static final int NOS_TIMES = 10;

  // warm up the JVM
  static void prerun() throws IOException, ClassNotFoundException  {
Label l = new Label(hi);
System.out.println(prerun);
makeLabelFromBytes(10, labelArray());
  }
  static void rungc() {
Runtime.getRuntime().gc();
Runtime.getRuntime().gc();
  }

  static void printTotalMemory() {
System.out.println(total=+Runtime.getRuntime().totalMemory());
  }

  static void printFreeMemory() {
System.out.println(free 

Re: Page De-Serialization and memory

2011-07-09 Thread richard emberson

I you run the little Java program I included, you will see that
there is an impact - de-serialized objects take more memory.

Richard

On 07/09/2011 05:23 PM, Igor Vaynberg wrote:

string literals are interned by the jvm so they should have a minimal
memory impact.

-igor

On Sat, Jul 9, 2011 at 5:10 PM, richard emberson
richard.ember...@gmail.com  wrote:

Martin,

The reason I was interested was because it struck me a couple of
days ago that while each Page, tree of Components, is created
many (almost all?) of the non-end-user-generated Strings stored
as instance variables in the tree are shared
between all copies of the Page but that when such a Page is
serialized to disk and then de-serialized, each String becomes its own
copy unique to that particular Page. This means that if an
appreciable number of Pages in-memory are reanimated Pages, then
there could be a bunch of memory being used for all the String
copies.

In the attached simple Java file (yes, I still write Java when I must)
there are three different ways of creating an array of
Label objects (not Wicket Label) where each Label takes a String:
new Label(some_string)

The first is to share the same String over all instance of the Label.
new Label(the_string)
The second is to make a copy of the String when creating each
Label;
new Label(new String(the_string))
The third is to create a single Label, serialize it to an array of
bytes and then generate the Labels in the array by de-serialized
the byte array for each Label.

Needless to say, the first uses the least memory; the label string
is shared by all Labels while the second and third approach
uses more memory. Also, if during the de-serialization process, the
de-serialized String is replaced with the original instance of the
String, then the third approach uses only as much memory as the
first approach.

No rocket science here, but it does seem to imply that if a
significant number of Pages in-memory are actually reanimated Pages,
then there could be a memory saving by
making de-serialization smarter about possible shared objects.
Even it it is only, say, a 5% saving for only certain Wicket
usage patterns, it might be worth looking into.

Hence, my question to the masters of Wicket and developers whose
application might fit the use-case.

Richard

On 07/09/2011 11:03 AM, Martin Makundi wrote:


Difficult to say ... we have disabled page versioning and se dump
sessions onto disk every 5 minutes to minimize memory hassles.

But I am no master ;)

**
Martin

2011/7/9 richard embersonrichard.ember...@gmail.com:


This is a question for Wicket masters and those application builders
whose application match the criteria as specified below.

[In this case, a Wicket master is someone with a knowledge
of how Wicket is being used in a wide spectrum of applications
so that they have a feel for what use-cases exist in the real world.]

Wicket is used in a wide range of applications with a variety of
usage patterns. What I am interested in are those applications where
an appreciable number of the pages in memory are pages that had
previously been serialized and stored to disk and then reanimated,
not found in an in-memory cache and had to be read from disk and
de-serialized back into an in-memory page; which is to say,
applications with an appreciable number of reanimated pages.

Firstly, do such applications exists? These are real-world
applications where a significant number of pages in-memory
are reanimated pages.

For such applications, what percentage of all pages at any
given time are reanimated pages?
Is it, say, a couple of percent? Two or three in which case its not
very significant.
Or, is it, say, 50%? Meaning that half of all pages currently in
memory had been serialized to disk, flushed from any in-memory cache
and then, as needed, de-serialized back into a Page.

Thanks

Richard
--
Quis custodiet ipsos custodes

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org




--
Quis custodiet ipsos custodes


-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org




--
Quis custodiet ipsos custodes

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Any site running 1.5-M3 examples

2011-01-06 Thread richard emberson


When a milestone release occurs, is there any site that runs the
example applications?

Richard
--
Quis custodiet ipsos custodes

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: Any site running 1.5-M3 examples

2011-01-06 Thread richard emberson

For the images example.
The site: http://wicketstuff.org/wicket14/
leads to:
http://wicketstuff.org/wicket14/images/
third image's html is:
img src=?wicket:interface=:0:image3::IResourceListener::/

while the site you reference:
http://wicketstuff.org/wicket/
for the images leads to:
http://wicketstuff.org/wicket/images/wicket/bookmarkable/org.apache.wicket.examples.images.Home?1
and the third image's html is:
img src=../page?2-IResourceListener-image3/

So, assuming that wicket14 is wicket 1.4 stuff,
the site you gave me matches what I get when I build
1.5-M3.

Thanks.

Richard

On 01/06/2011 05:00 PM, Igor Vaynberg wrote:

http://wicketstuff.org/wicket/


not sure what version it is but its some 1.5.x

-igor

On Thu, Jan 6, 2011 at 4:57 PM, richard emberson
richard.ember...@gmail.com  wrote:


When a milestone release occurs, is there any site that runs the
example applications?

Richard
--
Quis custodiet ipsos custodes

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org




--
Quis custodiet ipsos custodes

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: wicket-velocity velocimacro.library

2010-12-11 Thread richard emberson

Funny, just yesterday I was trying to get wicket-velocity to work.
So, I downloaded the velocity source and went code spelunking.
The singleton, org.apache.velocity.app,Velocity,
has a method setProperty which, if set before the init
method is called, allows you to override the velocimacro.library
property.
The Velocity.init method is called in 
org.apache.wicket.velocity.Initializer which, in turn,

is created and call from Application.scala (the wicket.properties
file contains: initializer=org.apache.wicket.velocity.Initializer
which is read by Application.scala). Now, Application.scala
does this work from the call to its initApplication method.
So, if you set the Velocity property before calling
Application.initApplication it should work.

I said, should, since this is not what I did; I simply commented
out the line
velocimacro.library = VM_global_library.vm
in the velocity.properties file.

An alternative is to find the VM_global_library.vm file in the
Velocity distribution (under test/templates) and put it where
it can be loaded. Again, I did not do this.

Richard

On 12/10/2010 08:08 PM, fachhoch wrote:


I want to use   wicketstuff  yui  and this has dependency on wicket-velocity
, this was failing my application becasue of property

velocimacro.library = VM_global_library.vm



its working after  disabling the property , I disabled the porperty by
modifying the velocity.property from the jar wicket-velocity.jar  , Please
tell me how to remove this  property programatically.


--
Quis custodiet ipsos custodes

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



BUG: Form Bytes getMaxSize

2010-11-05 Thread richard emberson

In org/apache/wicket/markup/html/form/Form the method getMaxSize
always returns a Bytes instance.


  public Bytes getMaxSize() {
Bytes maxSize = this.maxSize;
if (maxSize == null) {
  maxSize = visitChildren(Form.class, new IVisitorForm?, Bytes() {
public void component(Form? component, IVisitBytes visit) {
  Bytes maxSize = component.getMaxSize();
  if (maxSize != null) {
visit.stop(maxSize);
  }
}
  });
}
if (maxSize == null) {
  return 
getApplication().getApplicationSettings().getDefaultMaximumUploadSize();

}
return maxSize;
  }

Because during the visit traversal, the VERY FIRST Form visited returns
a non-null getMaxSize value. Even it its this.maxSize is null, it
will then return getDefaultMaximumUploadSize.

I suspect what is needed is a isMaxSizeSet method.
The inner visit method would then be:


if (component.isMaxSizeSet()) {
  Bytes maxSize = component.getMaxSize();
  visit.stop(maxSize);
}

With this, then it is only the Form creating and calling the Visitor
that returns the getDefaultMaximumUploadSize value, and only if
none of its sub Forms have an explicit value.

Also, should the Visitor actually look for the maximum size value
of the children and return it rather than returning the first
value (which may not be the maximum)???

Richard
--
Quis custodiet ipsos custodes

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: code review: org.apache.wicket.pageStore.AsynchronousDataStore.removeData

2010-10-19 Thread richard emberson

I've submitted such items to the dev list and got no reply.
At least here some knowledgeable user may look at the code
and provide feedback.

On 10/19/2010 07:30 AM, John Owen wrote:

Shouldn't this be on the dev mailing list instead?

-Original Message-
From: richard emberson [mailto:richard.ember...@gmail.com]
Sent: Monday, October 18, 2010 8:50 PM
To: users@wicket.apache.org
Subject: code review: 
org.apache.wicket.pageStore.AsynchronousDataStore.removeData

org.apache.wicket.pageStore.AsynchronousDataStore.removeData

A little code review please:

In org.apache.wicket.pageStore.AsynchronousDataStore

  public void removeData(final String sessionId, final int id)
  {
  synchronized (WRITE_LOCK)
  {
  String key = getKey(sessionId, id);
  if (key != null)
  {
  entryMap.remove(key);
  }
  Entry entry = entryMap.get(key);
  if (entry != null)
  {
  entries.remove(entry);
  }
  }
  dataStore.removeData(sessionId, id);
  }

After removing the Entry from the entryMap, why is there
an attempt to get the Entry?
Is the get there for the case when the key is null?
  From the getKey code it does not look like the key will
ever be null.

This code is in apache-wicket-1.5-M2.1

Richard



--
Quis custodiet ipsos custodes

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: code review: org.apache.wicket.pageStore.AsynchronousDataStore.removeData

2010-10-19 Thread richard emberson



I am simply in the process of looking into Wicket; reading one
of the Wicket books, lurking on the mailing list and reviewing
the code and comments.
I have not yet determined at what level I might become involved
with Java Wicket.
The code in this particular message thread I did not grok, so
I asked about it.

Thanks.

Richard

On 10/19/2010 07:58 AM, Martin Grigorov wrote:

On Tue, Oct 19, 2010 at 4:40 PM, richard emberson
richard.ember...@gmail.com  wrote:


I've submitted such items to the dev list and got no reply.


Hm, I don't remember seeing this in d...@. But I don't remember many other
things too :-)


At least here some knowledgeable user may look at the code
and provide feedback.


File it as a ticket in Jira and it will definitely get attention ;-)
Complemented with a patch would be lovely!




On 10/19/2010 07:30 AM, John Owen wrote:


Shouldn't this be on the dev mailing list instead?

-Original Message-
From: richard emberson [mailto:richard.ember...@gmail.com]
Sent: Monday, October 18, 2010 8:50 PM
To: users@wicket.apache.org
Subject: code review:
org.apache.wicket.pageStore.AsynchronousDataStore.removeData

org.apache.wicket.pageStore.AsynchronousDataStore.removeData

A little code review please:

In org.apache.wicket.pageStore.AsynchronousDataStore

  public void removeData(final String sessionId, final int id)
  {
  synchronized (WRITE_LOCK)
  {
  String key = getKey(sessionId, id);
  if (key != null)
  {
  entryMap.remove(key);
  }
  Entry entry = entryMap.get(key);
  if (entry != null)
  {
  entries.remove(entry);
  }
  }
  dataStore.removeData(sessionId, id);
  }

After removing the Entry from the entryMap, why is there
an attempt to get the Entry?
Is the get there for the case when the key is null?
  From the getKey code it does not look like the key will
ever be null.

This code is in apache-wicket-1.5-M2.1

Richard



--
Quis custodiet ipsos custodes

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org






--
Quis custodiet ipsos custodes

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



Re: MarkupContainer's ComponentSourceEntry

2010-10-18 Thread richard emberson

If I might ask a couple of follow-up questions?

Is the primary driver for having the ability to
dehydrate Components:
1) Lessening in-memory RAM usage,
2) Faster serialization,
3) Network transmission speed for machine-to-machine
transfer of Components, or
4) Lessening disk usage when Components are stored on
disk?

Next, regardless of the driver, they are all good goals.
Was any consideration given to refactoring the Object/Interface
hierarchy so that 1) MarkupContainer could simply hold
one type of Object (an IComponent) with an API that supports
the wet/dry water state of Components (this would simplify
the MarkupContainer code) and 2) maybe have a higher-level
hydration interface so that things other than Components
could support wet/dry states?

For example (only):

IHydratable
  boolean isHydrated()
  Object hydrated()
  Object dehydrated()

  IComponent extends IHydratable
Component hydrated(Component parent)
ComponentSourceEntry dehydrate(Component parent)

ComponentSourceEntry implements IComponent
  boolean isHydrated() { return false; }
  Component hydrated(Component parent) {
Component comp = (Component)hydrated()
.
return comp
  }
  ComponentSourceEntry dehydrate(Component parent) { return this;  }

Component implements IComponent
  boolean isHydrated() { return true; }
  Component hydrated(Component parent) { return this; }
  ComponentSourceEntry dehydrate(Component parent) {
ComponentSourceEntry compSE = (ComponentSourceEntry)dehydrated()
.
return compSE
  }

Thanks

Richard


On 10/14/2010 11:20 AM, Igor Vaynberg wrote:

this is an experimental feature that hasnt quiet been finished yet.
see IComponentSource.

-igor

On Thu, Oct 14, 2010 at 10:15 AM, richard emberson
richard.ember...@gmail.com  wrote:

The MarkupContainer's ComponentSourceEntry is a private class with a
private constructor. No where in the MarkupContainer code is an
instance of ComponentSourceEntry created.
Is ComponentSourceEntry something on its way out or some feature
yet to be engaged?

Richard
--
Quis custodiet ipsos custodes

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org




-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org




--
Quis custodiet ipsos custodes

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



code review: org.apache.wicket.pageStore.AsynchronousDataStore.removeData

2010-10-18 Thread richard emberson

org.apache.wicket.pageStore.AsynchronousDataStore.removeData

A little code review please:

In org.apache.wicket.pageStore.AsynchronousDataStore

public void removeData(final String sessionId, final int id)
{
synchronized (WRITE_LOCK)
{
String key = getKey(sessionId, id);
if (key != null)
{
entryMap.remove(key);
}
Entry entry = entryMap.get(key);
if (entry != null)
{
entries.remove(entry);
}
}
dataStore.removeData(sessionId, id);
}

After removing the Entry from the entryMap, why is there
an attempt to get the Entry?
Is the get there for the case when the key is null?
From the getKey code it does not look like the key will
ever be null.

This code is in apache-wicket-1.5-M2.1

Richard

--
Quis custodiet ipsos custodes

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org



MarkupContainer's ComponentSourceEntry

2010-10-14 Thread richard emberson

The MarkupContainer's ComponentSourceEntry is a private class with a
private constructor. No where in the MarkupContainer code is an
instance of ComponentSourceEntry created.
Is ComponentSourceEntry something on its way out or some feature
yet to be engaged?

Richard
--
Quis custodiet ipsos custodes

-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org